package cn.com.nes.site.action.monitor;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.service.monitor.EquipmentInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller("equipmentInfo")
@RequestMapping("/equipmentInfo")
public class EquipmentInfoController {

    @Resource
    EquipmentInfoService equipmentInfoService;

    @RequestMapping(method = RequestMethod.POST, value = "/getCardInfo")
    public @ResponseBody
    PageData getCardInfo(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        return equipmentInfoService.getCardInfo(reqStatus.getReq());
    }


    @RequestMapping(method = RequestMethod.POST, value = "/deleteEquipmentInfoBysbId")
    public  @ResponseBody
    PageData deleteEquipmentInfoBysbId(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.delEquipmentById(reqStatus.getReq());
        return res;
    }


    @RequestMapping(method = RequestMethod.POST, value = "/bindEquipment")
    public @ResponseBody
    PageData bindEquipment(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.bindEquipment(reqStatus.getReq());
        return res;
    }


    @RequestMapping(method = RequestMethod.POST, value = "/getWxList")
    public  @ResponseBody
    PageData getWxList(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.getWxList(reqStatus.getReq());
        return res;
    }

    @RequestMapping(method = RequestMethod.POST, value = "/getEquipment")
    public @ResponseBody
    PageData getEquipment(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.getEquipment(reqStatus.getReq());
        return res;
    }

    @RequestMapping(method = RequestMethod.POST, value = "/getSbCountByXzqh")
    public @ResponseBody
    PageData getSbCountByXzqh(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.getSbCountByXzqh(reqStatus.getReq());
        return res;
    }

    @RequestMapping(method = RequestMethod.POST, value = "/getSbCountByBrand")
    public @ResponseBody
    PageData getSbCountByBrand(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.getSbCountByBrand(reqStatus.getReq());
        return res;
    }


    @RequestMapping(method = RequestMethod.POST, value = "/getSbCountBySjly")
    public @ResponseBody
    PageData getSbCountBySjly(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.getSbCountBySjly(reqStatus.getReq());
        return res;
    }

    @RequestMapping(method = RequestMethod.POST, value = "/getSbCountByEquipmentType")
    public @ResponseBody
    PageData getSbCountByEquipmentType(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.getSbCountByEquipmentType(reqStatus.getReq());
        return res;
    }

}
